<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of user
 *
 * @author agasi
 */
class User_ajax extends CI_Controller {
    
    function __construct() 
    {
        parent::__construct();
        $this->load->model('sistem/user_model');
        $this->load->library('flexigrid');
//        $this->output->enable_profiler(TRUE);
    }
    
    function index()
    {
        $valid_fields = array('user_id','user_nama','user_real_nama','user_email','user_status');
		
        $this->flexigrid->validate_post('user_id','asc',$valid_fields);

        $records = $this->user_model->get_all_user();

        $this->output->set_header($this->config->item('json_header'));

        /*
            * Json build WITH json_encode. If you do not have this function please read
            * http://flexigrid.eyeviewdesign.com/index.php/flexigrid/example#s3 to know how to use the alternative
            */
        $record_items = array();
        foreach ($records['records']->result() as $row)
        {
                $record_items[] = array($row->user_id,
                $row->user_id,
                $row->user_nama,
                $row->user_real_nama,
                $row->user_email,
                $row->user_status,
                '<a href=\'http://localhost/\'><img border=\'0\' src=\''.$this->config->item('base_url').'public/images/close.png\'></a> '
                );
        }
        //Print please
        $this->output->set_output($this->flexigrid->json_build($records['record_count'],$record_items));
    }

    function deletec()
    {
        
//        $countries_ids_post_array = split(",",$this->input->post('items'));
//
//        foreach($countries_ids_post_array as $index => $country_id)
//                if (is_numeric($country_id) && $country_id > 1) 
//                        $this->ajax_model->delete_country($country_id);

        	
        $error = "Selected sys_user (id's: ".$this->input->post('items').") deleted with success. Disabled for demo";

        $this->output->set_header($this->config->item('ajax_header'));
        $this->output->set_output($error);
    }
}

/* End of file user_ajax.php */
/* Location: ./application/controllers/sistem/user_ajax.php */